#include "cd.hpp"
#include "cas.hpp"
#include "cvm.hpp"
#include <iostream>

int main(int argc, char** argv) {
    if(argc == 1) {
        std::cout << "cd language v1.0.0 2024/8/19\n"
                  << "usage:\n"
                  << "  cd xx.cd\n";
    }

    for(int i = 1; i < argc; i ++) {
        std::string input = argv[i];

        Cd cd;
        cd.init(input, input + ".s");
        cd.parser() -> codegen();
        cd.output_file.close();

        Cas cas;
        cas.init(input + ".s", input + ".bin");
        cas.compile();
        cas.write_filemsg();
        cas.output_file.close();

        Cvm cvm;
        cvm.load_file(input + ".bin");
        cvm.execute();
    }
}